<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div[class^=x]{
            color: red;
        }
        div[class$=x]{
            color: skyblue;

        }
    </style>
</head>
<body>
    <div class="x-1">1</div>
    <div class="x-2">2</div>
    <div class="x-3">3</div>
    <div class="1-x">4</div>
    <div class="2-x">5</div>
    <div class="3-x">6</div>
</body>
</html>